﻿
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_LayoutFront.cshtml";
}
@model List<Blog190311.Models.DBModel.Article>
<aside>
    <div class="l_box">
        <div class="search">
            @Html.Action("Share", "PartialView")
        </div>
        <div class="fenlei">
            @Html.Action("MyWord", "PartialView")
        </div>
        <div class="tuijian">
            @Html.Action("MyTuiJian", "PartialView")
        </div>
        <div class="tuijian">
            @Html.Action("MyClick", "PartialView")
        </div>
        <div class="cloud">
            @Html.Action("MyCloud", "PartialView")
        </div>
        <div class="guanzhu">
            <h2>关注我 么么哒</h2>
            <ul>
                <img src="~/images/wx.jpg">
            </ul>
        </div>
    </div>
</aside>
<div class="r_box">
    <main>
        @foreach (var item in this.Model)
        {
            <li>
                <i><a href="~/Article/Detail/@item.Id"><img src="~/@item.MainPicUrl"></a></i>
                <h3><a href="~/Article/Detail/@item.Id">@item.Title</a></h3>
                <p>@item.SimpleInfo</p>
            </li>
        }
        <div id="pagelist">
</div>
    </main>
</div>
<script>
    layui.use('laypage', function () {
        var laypage = layui.laypage;
        //执行一个laypage实例
        laypage.render({
            elem: 'pagelist'
            , count:@ViewBag.total//数据总数，从服务端得到
            , limit: @ViewBag.limit
            , curr: @ViewBag.page
            , jump: function (obj, first) {
                //ob包含了当前分页的所有参数，比如:
                console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
                console.log(obj.limit); //得到每页显示的条数
                //首次不执行
                if (!first) {
                    //do something
                    var con = $('#keyboard').val();//获取到查询内容
                    var href = '/Article/Index?con='+con;
                    href += '&page=' + obj.curr;
                    href += '&limit='+ obj.limit;
                    console.log(href)
                    location.href = href;//页面跳转到指定页面
                }
            }
        });
    });
</script>